Skip to content

fix(worktree): link main checkout's .env into fresh worktrees on setup - #123

Closed
robercano wants to merge 1 commit into
mainfrom
fix/worktree-env-bootstrap
Closed

fix(worktree): link main checkout's .env into fresh worktrees on setup#123
robercano wants to merge 1 commit into
mainfrom
fix/worktree-env-bootstrap

Conversation

@robercano

Copy link
Copy Markdown
Owner

Problem

Subagents working in isolated worktrees (implementers, reviewers, test-runners) can't run tasks that need credentials: .env is gitignored, so a fresh git worktree add checkout never contains it, and gates/scripts fail for lack of GH_BOT_TOKEN / RPC URLs rather than real defects.

Fix

worktree.sh setup now symlinks the main checkout's .env into the worktree — the same pattern prepare-pr.sh already uses for test-pr worktrees.

Tests

New worktree.test.sh (auto-discovered by checks.sh test): 11 checks — fresh-worktree link + content, local-.env precedence, main-checkout no-op, missing-.env no-op, teardown no-op, and check-ignore confirming the link stays gitignored.

Gates run locally: buildlinttest (all script smokes incl. new one) ✅ smoke-fanout

🤖 Generated with Claude Code

Isolated implementer/reviewer worktrees are fresh checkouts, and .env is
gitignored — so it never appears in them, and any gate or script that
needs its credentials (GH_BOT_TOKEN, RPC URLs, ...) fails for lack of
setup rather than a real defect.

worktree.sh setup now symlinks the main checkout's .env into the
worktree (same pattern prepare-pr.sh already uses for test-pr
worktrees): resolved from the caller's cwd so it works in both the
repo-tracked and plugin-cache layouts, best-effort, and skip-if-present
so a worktree-local .env always wins. Runs before the adapter checks so
unconfigured repos get it too.

Ships in the plugin's scripts/ — consumers pick it up on plugin update
with no adapter (gates.json) change needed.

Adds worktree.test.sh (auto-discovered by checks.sh test): 11 checks
covering fresh-worktree link, local-.env precedence, main-checkout
no-op, missing-.env no-op, teardown no-op, and gitignore coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Superseded — recreated as a bot-authored PR so the repo owner can formally approve it (GitHub blocks PR authors from approving their own PRs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants